package com.common.help;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;

import com.common.R;
import com.common.util.DisplayUtil;


/**
 * Created by qyang on 2018-3-2.
 */

public class RecycleViewHelp {
    public static void setManager(RecyclerView recyclerView,Context context){
        LinearLayoutManager manager = new LinearLayoutManager(context);
        recyclerView.setLayoutManager(manager);

    }
    public static void setManager(RecyclerView recyclerView,int drawbleId, Context context){
        recyclerView.addItemDecoration(new RecycleViewDivider(context,
                LinearLayoutManager.VERTICAL, drawbleId));
        LinearLayoutManager manager = new LinearLayoutManager(context);
        recyclerView.setLayoutManager(manager);
    }
    public static void setManager(RecyclerView recyclerView,int drawbleId,int animId, Context context){
        recyclerView.addItemDecoration(new RecycleViewDivider(context,
                LinearLayoutManager.VERTICAL, drawbleId));
        LinearLayoutManager manager = new LinearLayoutManager(context);
        recyclerView.setLayoutManager(manager);
        LayoutAnimationController animation = AnimationUtils.loadLayoutAnimation(context, animId);
        recyclerView.setLayoutAnimation(animation);
    }

    public static void setGridMannager(RecyclerView recycleView,int dp,int num,Context context){
        GridLayoutManager manager = new GridLayoutManager(context,num);
        recycleView.setLayoutManager(manager);
        recycleView.addItemDecoration(new GridRecycleViewDivider(DisplayUtil.dp2px(context,dp)));
    }

    public static void setHorizontalManager(RecyclerView recyclerView,int drawbleId,  Context context){
        recyclerView.addItemDecoration(new RecycleViewDivider(context,
                LinearLayoutManager.VERTICAL, drawbleId));
        LinearLayoutManager manager = new LinearLayoutManager(context);
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(manager);
    }


}
